package main

import (
	"os"
	"os/exec"
	"strings"
	"time"
)

func ClearCmd() {
	cmd := exec.Command("cmd", "/c", "cls")
	cmd.Stdout = os.Stdout
	cmd.Run()
}

func ErrorCollector(path string,err error,AdditionalStr string) {
	add:=""
	if AdditionalStr!="" {
		add="**"+AdditionalStr+"**"
	}
	fd,_:=os.OpenFile(path,os.O_RDWR|os.O_CREATE|os.O_APPEND,0644)
	nowTime:=time.Now().Format("2006-01-02 15:04:05")
	Content:=strings.Join([]string{"======",nowTime,"=====",add,err.Error(),"\n"},"")
	buf:=[]byte(Content)
	fd.Write(buf)
	fd.Close()
	os.Exit(1)
}